<template>
  <div>
    <basic-container>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>作者平台管理</el-breadcrumb-item>
        <el-breadcrumb-item>PC站运营</el-breadcrumb-item>
        <el-breadcrumb-item>自动回复模板</el-breadcrumb-item>
      </el-breadcrumb>
    </basic-container>
    <basic-container>
      <avue-crud
        :table-loading="loading"
        ref="crud"
        :data="data"
        v-model="form"
        :option="option"
        :page.sync="page"
        @on-load="getList"
        @refresh-change="refreshChange"
        @search-reset="from = {}"
        @search-change="searchChange"
        @row-update="rowUpdate"
        @row-del="rowDel"
        @row-save="rowSave"
      >
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import { common } from "@/api/cat/httpRequest";
import { catUrl } from "@/config/env";
import { pcConfigMessageTemplate,selectTemplate } from "@/api/cat/baseUrls";
export default {
  data() {
    return {
      loading: false,
      page: {
        total: 0,
        pageSize: 10,
      },
      type: true,
      data: [],
      params: {},
      form: {},
      default: {
        orderByList: "create_time&DESC",
      },
      option: {
        index: true,
        indexLabel: "序号",
        excelBtn: false,
        border: true,
        column: [
          {
            label: "模板名称",
            prop: "title",
            type: "input",
            search: false,
            row: true,
            rules: [
              {
                required: true,
                message: "",
              },
            ],
            addDisplay: true,
            editDisplay: false,
            editDisabled: true,
          },
          {
            label: "模板简介",
            prop: "intro",
            type: "input",
            dicData: [],
            row: true,
            rules: [
              {
                required: true,
                message: "",
              },
            ],
          },
          {
            label: "模板内容",
            prop: "content",
            type: "textarea",
            span: 24,
            row: true,
            rules: [
              {
                required: true,
                message: "推送内容必须填写",
              },
            ],
          },
          {
            label: "创建人",
            prop: "edit_account",
            type: "textarea",
            span: 24,
            row: true,
            rules: [
              {
                required: true,
                message: "推送内容必须填写",
              },
            ],
            addDisplay: false,
             editDisplay: false,
          },
          {
            label: "创建时间",
            prop: "create_time",
            type: "input",
            // slot: true,自定义单元格内容
            addDisplay: false,
            editDisplay: false,
            addDisabled: true,
            editDisabled: true,
          },
        ],
      },
    };
  },
  methods: {
    /**获取列表 */
    async getList() {
      let response = await common(
        pcConfigMessageTemplate.pageAndParam,
        {},
        this.page,
        'POST'
      )
      if(response.code==1){
        this.data = response.data
        this.page= response.page
      }
    },
    /**保存 */
    async rowSave(row, done, loading) {
      let response = await common(
        pcConfigMessageTemplate.save,
        this.form,
        {},
        "POST"
      );
      if (response.code == 1) {
        done();
        this.getList()
      }
      loading();
    },
    /**修改 */
    async rowUpdate(row, index, done, loading) {
      console.log(row,'row')
      let params = {
         id:row.id,
         edit_account:''
      }
      let res = await common(
       pcConfigMessageTemplate.update,
       {...this.form,...params},
       {},
       'POST'
      )
      if (res.code == 1) {
        done();
        this.getList()
      }
    },
    /**刷新 */
    refreshChange() {},
    /**删除 */
    rowDel(row) {},
    /**刷新 */
    refreshChange() {
      this.getList();
    },
    /**搜索 */
    searchChange(params, done) {},
  },
  mounted() {},
};
</script>